<template>
	<view style="padding-bottom: 200rpx;">
		<!-- <view  class="centre-top row" :style="`padding-top:${heightTop}rpx`"
			style="justify-content: space-around;align-items: center;">
			<zywork-icon @click="navTo('/pages/erro/erro')"  type="icon-xiaoxi1" color="#ffffff" size="50"></zywork-icon>
			<view class="row search" style="align-items: center;" @click="navTo('search')">
				<zywork-icon type="icon-sousuo" color="#ffffff" size="50"></zywork-icon>
				<text class="uni-list--sm" style="color: #FFFFFF;margin-left: 30rpx;">请输入搜索内容</text>
			</view>
			<zywork-icon @click="open" type="icon-kefu" color="#ffffff" size="50"></zywork-icon>
		</view> -->
		<view class="centre-top1 row" style="justify-content: space-around;position: relative;z-index: 1;"
			:style="`padding-top:${height}rpx`">
			<view @click="scan()" class="column align-items-center"
				style="width: 200rpx;height: 200rpx;margin-top: 20rpx;">
				<zywork-icon type="icon-saoyisao" color="#fff" size="100"></zywork-icon>
				<text style="color: #FFFFFF;font-size: 38rpx;margin-top: 10rpx;">扫一扫</text>
			</view>
			
			
			<view class="column align-items-center" style="width: 200rpx;height: 200rpx;margin-top: 20rpx;"
				@click="navTo('/pages/user/my-QR-code/my-QR-code')">
				<zywork-icon type="icon-erweima" color="#fff" size="100" style="transform:scale(0.9);"></zywork-icon>
				<text style="color: #FFFFFF;font-size: 38rpx;margin-top: 10rpx;">我的推荐码</text>
			</view>
		</view>
		<view class="centre-grid">
			<view class="row ">
				<view class="column" style="position: relative;" @click="navTo('/pages/index/make-money/make-money')">
					<image :class="'animation-' + animation" src="/static/index/icon_home_money.png" mode=""></image>
					<image v-if="isGif" :src="gifUrl" style="width: 400rpx;position: absolute;top: -40rpx;"
						mode="widthFix">
					</image>
					<text class="text-18">{{isAndroid?'我要赚钱':'每日任务'}}</text>
				</view>
				<view v-if="isAndroid" class="column" @click="reLaunch('/pages/tao-bao/tao-bao','TB')">
					<image src="/static/icon_home_taobao@2x.png" mode=""></image>
					<text class="text-18">淘宝省钱</text>
				</view>
				<view v-if="isAndroid" class="column" @click="reLaunch('/pages/tao-bao/tao-bao','PDD')">
					<image src="/static/icon_home_spell@2x.png" mode=""></image>
					<text class="text-18">拼多多省钱</text>
				</view>
				<view v-if="!isAndroid" class="column" @click="navTo('/pages/user/order/order_list')">
					<image src="/static/icon_my_order@3x.png" mode=""></image>
					<text class="text-18">我的订单</text>
				</view>
				<view v-if="!isAndroid" class="column" @click="navTo('/pages/user/feedback/feedback')">
					<image src="/static/icon_my_feedback@3x.png" mode=""></image>
					<text class="text-18">反馈中心</text>
				</view>
				<view class="column" @click="navTo('/pages/index/nearby-facility/nearby-facility')">
					<image src="/static/icon_home_equipment@2x.png" mode=""></image>
					<text class="text-18">附近设备</text>
				</view>
			</view>
			<!-- <noticeBar :speed="speed" textColor="#ff5500"
				style="width: 90%;position: absolute;bottom: -40rpx;z-index: 1;" :list="noticeList"></noticeBar> -->
		</view>
		<!-- <information-ad /> -->
		<view style="width: 90%;left: 5000rpx;margin: 0 auto;" :style="`position:${initial}`">
			<ad type="feeds"  guang :data="adData" @close="adClose">
			</ad>
		</view>

		<view @click="navTo('/pages/index/daily-Quest/daily-Quest')" class="row align-items-center"
			style="margin-top: 20rpx;">
			<image src="/static/image_capsule@3x.png" style="width: 720rpx;" mode="widthFix"></image>
		</view>
		<view class="row align-items-center" v-if="false">
			<!-- <image src="/static/image_capsule@3x.png" style="width: 720rpx;" mode="widthFix"></image> -->
			<image class="advertising-img" src="/static/ceshi/hangz.jpg" mode="scaleToFill">
			</image>
		</view>
		<view  style="padding: ;padding: 20rpx 20rpx;">
			<view  class="">
				<!-- <view class="row advertising " @click="showAd" style=""> -->
				<view v-for="(item,index) in thirdConfigList" v-show="item.isShow&&!item.dataValid"    class="row advertising " style="">	
					<image :src="item.imgUrl" mode="widthFix"></image>
					<view class="column " style="">
						<text class="text-lg" style="">{{item.title}}</text>
						<text class="text-sm">{{item.subtitle}}</text>
					</view>
					<view class="button" style="" @click="redPacket(item)">
						{{item.buttonTitle}}
					</view>
				</view>
				<!-- <view class="row advertising " style="">
					<image src="/static/index/Ele.png" mode="widthFix"></image>
					<view class="column ">
						<text class="text-lg">免费领饿了么红包</text>
						<text class="text-sm" style="">立马到账，优惠不停</text>
					</view>
					<view class="button" @click="redPacket(0)" style="">
						立即领取
					</view>
				</view>
				
				<view class="row advertising " style="">
					<image src="/static/index/meituan.png" mode="widthFix"></image>
					<view class="column ">
						<text class="text-lg">美团外卖红包</text>
						<text class="text-sm">免费领取，秒到账</text>
					</view>
					<view class="button" @click="redPacket(1)" style="">
						立即领取
					</view>
				</view>
				
				<view class="row advertising " style="">
					<image src="/static/index/KFC.png" mode="widthFix"></image>
					<view class="column ">
						<text class="text-lg">KFC在线点餐</text>
						<text class="text-sm">5折起</text>
					</view>
					<view class="button" @click="redPacket(2)" style="">
						立即点餐
					</view>
				</view>
				
				<view class="row advertising " style="">
					<image src="/static/index/Movie-Tickets.png" mode="widthFix"></image>
					<view class="column ">
						<text class="text-lg">看电影</text>
						<text class="text-sm">85折起</text>
					</view>
					<view class="button" @click="redPacket(3)" style="">
						立即购买
					</view>
				</view>
				
				<view class="row advertising " style="">
					<image src="/static/index/prepaid.png" mode="widthFix"></image>
					<view class="column ">
						<text class="text-lg">充话费</text>
						<text class="text-sm">95折起</text>
					</view>
					<view class="button" @click="redPacket(4)" style="">
						立即充值
					</view>
				</view>
				<view class="row advertising " style="">
					<image src="/static/index/didi.png" mode="widthFix"></image>
					<view class="column ">
						<text class="text-lg">滴滴专享出行</text>
						<text class="text-sm">最高8折起</text>
					</view>
					<view class="button" @click="redPacket(5)" style="">
						立即领券
					</view>
				</view> -->
			</view>

			<view class="" style="font-size: 40rpx;padding: 30rpx 0rpx;">
				动态资讯
			</view>
			<view class="article-list" style="padding: 30rpx 0rpx;">
				<view v-for="(item,index) in articleList" :key="index" @click="itemClick(index,item)" class="row"
					style="align-items: center;margin-bottom: 30rpx;">
					<image :src="item.raw.imgurl" mode="scaleToFill"></image>
					<view class="column column-article" style="">
						<view class="label" :contents="item.source">
							{{item.title}}
						</view>
						<view class="row label-text">
							<text
								style="color: #4589A6;overflow: hidden;text-overflow: ellipsis;width: 120rpx;height: 30rpx;white-space:nowrap;">{{item.type}}</text>
							<text style="margin-left: 20rpx;">{{item.readingQuantity}}阅读</text>
							<text style="margin-left: auto;">{{item.time}}</text>
						</view>
					</view>
				</view>
			</view>
			<view v-show="isLoadMore">
				<uni-load-more :status="loadStatus"></uni-load-more>
			</view>
			<!-- <z-paging :fixed="false" :refresherEnabled="false" style="height: 800rpx;" ref="paging"
				v-model="articleList" @query="queryList" :loadingMoreCustomStyle="{paddingBottom:'220rpx'}">
				
			</z-paging> -->
		</view>
		<custom-tab-bar :isAndroid="isAndroid" :current="1" @click="switchTabs"></custom-tab-bar>
		<uni-popup ref="alertDialog" type="dialog" :maskClick="false">
			<uni-popup-dialog type="warning" title="客服电话" :buttonArr="['取消','拨打']" :content="phoneNumber"
				@confirm="dialogConfirm" @close="dialogClose"></uni-popup-dialog>
		</uni-popup>

	</view>
</template>

<script>
	import {mapMutations,mapState} from 'vuex';
	import gcoord from 'gcoord';
	import informationAd from '@/components/ad/information-ad.vue'
	import APPUpdate, {
		getCurrentNo
	} from '@/uni_modules/zhouWei-APPUpdate/js_sdk/appUpdate';
	import noticeBar from '@/components/notice-bar/notice-bar.vue'
	import {
		urlList
	} from '@/common/picker-data.js'
	import permision from "@/js_sdk/wa-permission/permission.js" //引入权限判断，主要解决部分机型扫码出现问题
	export default {
		components: {
			informationAd,
			noticeBar
		},
		data() {
			return {
				noticeList: [], //中奖信息列表
				speed: 80, //中奖信息滚动速度
				articleContentItem: "企业文化",
				animation: 'shake', // 动画样式
				isGif: false,
				gifUrl: "/static/index/money.gif",
				heightTop: 25,
				height: 30,
				phoneNumber: "",
				articleList: [],
				articleIndex: 0,
				equipment: "",
				consultPage: 1,
				isShow: true,
				adData: {},
				initial: "initial",
				loadStatus: 'loading', //加载样式：more-加载前样式，loading-加载中样式，nomore-没有数据样式
				isLoadMore: false, //是否加载中
				loading: false,
				watchTheTime: 0, //快手视频计时
				timeVideo: null,
				requestCount: 0, //广告请求计数
				labelCount: 0, //判断标签是否设置过
				backButtonPress: 0 ,//监听退出应用的事件
				isAndroid:true ,//判断是否是安卓环境
				adOptions:{
					adpid: 1027948601
				},
				thirdConfigList:[] ,//配置信息
				systemInfo:"",
				hasUserInfo:false
			}
		},
		created() {
			uni.hideTabBar({})
			this.phoneNumber = this.$util.PHONE_NUMBER;
			this.articleList = []
			this.queryList()//资讯动态
			let i = 0
			this.noticeList = []
			while (i < 50) {
				this.getName();
				i++;
			}
			if(this.$environment ==='prod'){
				this.appUpdate();//查询是否有新版本需要更新
			}
		},
		computed: {
			...mapState(['codeResults']),
		},
		watch: {
			codeResults(res) {
				if(getCurrentPages().length==1){
					this.scanResult(res.result);
				}
			}
		},
		onPullDownRefresh() {
			this.articleList = []
			this.queryList()
			setTimeout(function() {
				uni.stopPullDownRefresh();
			}, 1000);
		},
		onLoad() {
			this.interval();
			this.systemInfo = uni.getSystemInfoSync();
			
			
			//动画效果初始化
			this.timerShake = setInterval(() => {
				this.animation = 'shake';
				this.interval();
			}, 4000)
			this.getProvinces();//加载省市区
			this.getAdData();//加载广告
			// 获取设备信息
			let that = this;
			plus.device.getInfo({
				success:e=>{
					console.log('设备信息1: ',e.uuid);
					
					uni.setStorageSync(this.$util.UUID,e.uuid)
				},
				fail:err=>{//如果获取失败则获取app生成的uuid
					// uni.setStorageSync("uuid",e.uuid)
					try {
						// console.log('设备信息2: ',res.deviceId);
						uni.setStorageSync(this.$util.UUID,this.systemInfo.deviceId)
					} catch (e) {
					    // error
					}
				}
			});
			setTimeout(()=>{
				if(this.hasUserInfo){
					this.getUserDevice()
				}
			},5000)
		},
		onShow() {
			this.isAndroid = getApp().globalData.isAndroid;
			if (this.initial == "absolute") {
				this.initial = "initial"
				this.$refs.alertDialog.close()
			}
			if (this.timeVideo) {
				clearInterval(this.timeVideo);
				this.timeVideo = null;
			}
			this.hasUserInfo = uni.getStorageSync(this.$util.HAS_USER_INFO)
			// uni.setStorageSync(this.$util.AUTH,false)
			// uni.removeStorageSync(this.$util.USER_TOKEN_KEY)
			// uni.setStorageSync(this.$util.HAS_USER_INFO,false)
			// #ifdef APP-PLUS
			
			if(this.hasUserInfo){
				this.getUserInfo();
				this.getThirdConfig();
				if(this.labelCount === 0){
					this.queryLable();//加载爱好标签
				}
			}else {
				this.labelCount = 1;
				this.userInfo= {
					phonenumber:"0000"
				}
			}
			// #endif
			let that = this;
			uni.onNetworkStatusChange(function(res) {
				console.log("网络信息", res.isConnected);
				if(!res.isConnected){
					that.$util.showInfoToast("网络连接已断开");
				}
				console.log(res.networkType);
			});
			this.getAPP();
		},
		onReachBottom() { //上拉触底函数
			if (!this.isLoadMore) { //此处判断，上锁，防止重复请求
				this.isLoadMore = true
				this.consultPage += 1
				this.queryList()
			}
		},
		onNavigationBarSearchInputClicked() {
			this.navTo('search')
		},
		onNavigationBarButtonTap({
			index
		}) {
			if (index === 0) {
				this.navTo('/pages/index/message/message');
			} else {
				this.open();
			}
		},
		onBackPress() {
			this.backButtonPress++;
			if (this.backButtonPress > 1) {
				this.logout();
				plus.runtime.quit();
			} else {
				plus.nativeUI.toast('再按一次退出应用');
			}
			setTimeout(function() {
				this.backButtonPress = 0;
			}, 1000);
			return true;
		},
		methods: {
			//告诉APP.vue 生命周期停止统计在线时长
			...mapMutations(['logout']),
			...mapMutations(['setWatchTime']),
			ceshi(){
				var SubscribeMessage = plus.android.importClass("com.tencent.mm.opensdk.modelbiz.SubscribeMessage");
				console.log(SubscribeMessage)
				var subsMessageReq = new SubscribeMessage.Req();
				subsMessageReq.plusSetAttribute("scene", 1234); // 随便一个整数，0-10000以内
				subsMessageReq.plusSetAttribute("templateID", "h0QaI6rFI8z2yuSSlY1s4ah2UANzGwVD4lKmfLXjcV0"); // 在微信开放后台，可以查看自己应用的APPID对应的templateID
				
				var IWXAPI = plus.android.importClass("com.tencent.mm.opensdk.openapi.IWXAPI");
				var WXAPIFactory = plus.android.importClass("com.tencent.mm.opensdk.openapi.WXAPIFactory");
				var wxapi = WXAPIFactory.createWXAPI(plus.android.runtimeMainActivity().getContext(), "wx08bd57edafa2a1b5"); // appid是你自己微信的appid
				
				const a = wxapi.sendReq(subsMessageReq);
				console.log("微信回调",wxapi)
			},
			getUserDevice(){
				let data = {
					deviceId:this.systemInfo.deviceId,//系统唯一编码
					language:this.systemInfo.language,//系统语言
					systemEdition:this.systemInfo.system,//系统版本
					manufacturer:this.systemInfo.brand,//设备型号
					systemName:this.systemInfo.platform,//系统名称
					supplier:this.systemInfo.brand,//系统供应商
					model:this.systemInfo.model //设备型号
				}
				this.$util.doPostJson("/userDevice/add", data,{},true).then(res => {
					if (res.data.code == this.$ResponseStatus.OK) {
						// 兼容之前的版本（updateType是新版才有的参数）
						console.log("提交成功",data)
					}else {
						
					}
				});
			},
			onadload(e) {
			      console.log("onload");
			},
			onaderror(e) {
			  console.log("onerror");
			},
			//缓存APP版本信息
			getAPP(){
				let httpData = {
					vn:0
				}
				this.$util.doPostForm("/version/versionNumber", httpData,{},false).then(res => {
				    /* res的数据说明
				     * | 参数名称        | 一定返回     | 类型        | 描述
				     * | -------------|--------- | --------- | ------------- |
				     * | versionCode     | y        | int       | 版本号        |
				     * | versionName     | y        | String    | 版本名称      |
				     * | downloadUrl     | y        | String    | 版本下载链接（IOS安装包更新请放跳转store应用商店链接,安卓apk和wgt文件放文件下载链接）  |
				     */
					if (res.data.code == this.$ResponseStatus.OK) {
						// 兼容之前的版本（updateType是新版才有的参数）
						uni.setStorageSync(this.$util.APP_VERSION,res.data.data)
					}else {
					}
				});
			},
			async getUserTime() {
				const {
					data
				} = await this.$util.doGet(`/report/selectOnlinetime`, {}, {}, true)
				if (data.code == this.$ResponseStatus.OK) {
					this.time = data.data
					this.setWatchTime(this.time)
				} else { //接口请求失败的处理
					this.setWatchTime(0)
				}
			},
			async getThirdConfig() {
				const {
					data 
				} = await this.$util.doGet(`/thirdConfig/list`, {}, {}, true)
				if (data.code == this.$ResponseStatus.OK) {
					this.thirdConfigList = data.data.list
					this.thirdConfigList.forEach(item =>{
						if(item.showStatus === 2){
							item.isShow = true
						}else if(this.isAndroid && item.showStatus === 1){
							item.isShow = true
						}else if (!this.isAndroid && item.showStatus === 0){
							item.isShow = true
						}
					})
					this.$forceUpdate();
					console.log("配置信息",this.thirdConfigList)
				} else { //接口请求失败的处理
				}
			},
			getMovieTicketsAuthorization() {
				if (this.authStatus) {
					return
				}
				this.authStatus = true
				this.$util.doGet("/live/getLiveUrl", {}, {}, true).then(res => {
					if (res.data.code == this.$ResponseStatus.OK) {
						if (res.data.data) {
							this.navTo("/pages/common/common?weburl=" + res.data.data)
						}
					}
					setTimeout(() => {
						this.authStatus = false
					}, 1000)
				}).catch(error => {
					console.log(error)
				})
			},
			getKfcAuthorization() {
				if (this.authStatus) {
					return
				}
				this.authStatus = true
				this.$util.doGet("/kfc/getKfcUrl", {}, {}, true).then(res => {
					if (res.data.code == this.$ResponseStatus.OK) {
						if (res.data.data) {
							console.log("KFC",res.data.data)
							this.navTo("/pages/common/common?weburl=" + res.data.data)
						}
					}
					setTimeout(() => {
						this.authStatus = false
					}, 1000)
				}).catch(error => {
					console.log(error)
				})
			},
			async requestAndroidPermission(permisionID) {
				var result = await permision.requestAndroidPermission(permisionID)
				var strStatus
				if (result == 1) {
					strStatus = "已获得授权"
				} else if (result == 0) {
					strStatus = "未获得授权"
				} else {
					strStatus = "被永久拒绝权限"
				}
				return result
			},
			redPacket(item) {
				this.$util.accessPage(item.id)
				if (item.type ===0){
					this.navTo(item.url)
				}else if(item.type ===1){
					plus.runtime.openURL(item.url);
				}else if (item.type ===2){
					if(item.title.indexOf("KFC")!= -1){
						this.getKfcAuthorization();
					}else if (item.title.indexOf("电影")!= -1){
						this.getMovieTicketsAuthorization();
					}
				}else if (item.type ===3){
					this.navTo(`/pages/common/common?weburl=${item.url}`)
				}
			},
			//走马灯数据
			getName() {
				let family_name_str =
					"赵钱孙李周吴郑王冯陈褚卫蒋沈韩杨朱秦尤许吕施张孔曹严华金魏陶姜戚谢邹喻柏水窦章云苏潘葛奚范彭郎鲁韦昌马苗凤花方俞任袁柳酆鲍史唐费廉岑薛雷贺倪汤滕殷罗毕郝邬安常乐于时傅皮卞齐康伍余元卜顾孟平黄和穆萧尹";
				let family_name_index = Math.floor(Math.random() * family_name_str.length) + 1
				let family_name = family_name_str.substring(family_name_index, family_name_index + 1);
				let name = family_name + "***累计提现了" + (Math.floor(Math.random() * 10) + 1) * 10 + "元";
				this.noticeList.push(name)
			},
			//快手内容联盟
			showAd() {
				if (this.labelCount === 0) {
					this.navTo("/pages/index/interest/interest")
					return;
				}
				if(!this.userInfo.phonenumber&&this.isAndroid){
					this.navTo("/pages/user/my-setting/update-Phone/update-Phone")
					return;
				}
				if (this.loading) {
					return;
				}
				// uni.setStorageSync(this.dayTime,3600)
				this.loading = true;
				plus.ad.showContentPage(this.adOptions, (res) => {
					this.loading = false;
					this.timeVideo = setInterval(() => {
						this.watchTheTime++
						if (this.watchTheTime != 0 && this.watchTheTime % 60 == 0) {
							console.log(this.watchTheTime)
							uni.setStorageSync(this.dayTime, this.watchTheTime)
						}
					}, 1000)
				}, (err) => {
					this.loading = false;
					console.log(err);
				});
			},
			//APP更新请求
			appUpdate() {
				getCurrentNo(res => {
					// 进页面获取当前APP版本号（用于页面显示）
					this.version = res.version;
				});
				APPUpdate(false);
			},
			adClose() {
				this.initial = "absolute"
			},
			//加载信息流广告
			getAdData() {
				// 仅APP平台支持
				// 1862455929
				let screenHeight = uni.getSystemInfoSync().screenHeight
				let adpid = 1433206601
				if(screenHeight>780){//屏幕高度大于780的才展示视频广告
					adpid = 1131480982;
				}
				plus.ad.getAds({
						adpid: adpid, // 替换为自己申请获取的广告位标识，此广告位标识仅在HBuilderX标准基座中有效，仅用于测试
						count: 3, // 广告数量，默认 3
					},
					(res) => {
						// 注意: 广告数据只能使用一次
						this.adData = res.ads[0];
						this.requestCount = 0
					},
					(err) => {
						console.log(err);
						if (err.code === -5005 && this.requestCount !== 3) {
							this.requestCount++
							this.getAdData();
						}
					}
				)

			},
			//拨打客服电话把信息流广告隐藏起来
			open() {
				// this.isShow = false
				this.initial = "absolute"
				this.$refs.alertDialog.open()
			},
			closeDialog() {
				this.$refs.alertDialog.close()
				this.initial = "initial"
			},
			//查询用户是否设置过标签
			queryLable() {
				this.$util.doGet("/label/userOneLabelList", {}, {}, true).then(res => {
					console.log("查询标签是否设置",res)
					if (res.data.code == this.$ResponseStatus.OK) {
						this.labelCount = res.data.rows.length;
					}
				}).catch(error => {
					this.labelCount = 1
					console.log(error)
				})
			},
			async getMicInforList(page = this.consultPage) {
				try {
					const {
						data: {
							code,
							message,
							data: {
								list,
								pageNum,
								pageSize
							},
						}
					} = await this.$util.getMicInforList(page)
					if (code == this.$ResponseStatus.OK) {
						if (list) {
							if (list.length < pageSize) {
								this.isLoadMore = true
								this.loadStatus = 'nomore'
							} else {
								this.isLoadMore = false
							}
							if (pageNum == page) {
								return list.map(it => {
									return {
										title: it.articleTitle,
										source: it.subtopics,
										type: it.publisher,
										readingQuantity: it.pageView,
										time: it.releaseTime,
										raw: it
									}
								})
							} else {
								this.isLoadMore = true
								this.loadStatus = 'nomore'
								return []
							}

						} else {
							this.isLoadMore = true
							this.loadStatus = 'nomore'
							return []
						}
					} else { //接口请求失败的处理
						uni.showToast({
							title: message,
							icon: 'none'
						})
						this.isLoadMore = false
						if (this.consultPage > 1) {
							this.consultPage -= 1
						}
					}

				} catch (e) {
					console.warn(e)
					return []
				}
			},
			 getUserInfo() {
				this.$util.doGet('/user/manager/userInfoList', {}, {}, true).then(res => {
					if (res.data.code == this.$ResponseStatus.OK) {
						uni.setStorageSync(this.$util.USER_INFO, res.data.data)
						this.userInfo = res.data.data
						this.dayTime = "user_"+this.userInfo.rcode+'_1'+this.$util.getTime().split(" ")[0]
						if (uni.getStorageSync(this.dayTime)) {
							this.watchTheTime = uni.getStorageSync(this.dayTime)
						}
						this.getUserTime();
						console.log("用户个人信息",this.userInfo)
						this.$forceUpdate();
					}
				}).catch(error => {
					console.log(error)
				})
			},
			//加载省市区三级联动数据
			getProvinces() {
				this.$util.doGet('/region/getRegionList', {}, {}, true).then(res => {
					if (res.data.code == this.$ResponseStatus.OK) {
						uni.setStorageSync(this.$util.PROVINCE, res.data.data)
					}
				}).catch(error => {
					console.log(error)
				})
			},
			scan() {
				if (uni.getSystemInfoSync().platform == 'ios') {
					uni.scanCode({
						success: res => {
							uni.showLoading({
								title: "开始识别"
							})
							this.scanResult(res.result);
						}
					})
				} else {
					this.requestAndroidPermission('android.permission.CAMERA').then(res => {
						console.log("权限状态",res)
						if(res){
							getApp().getScan().scanCode()
						}
					}).catch(error => {
						console.log(error)
					})
				}
			},
			scanResult(result) {
				uni.showLoading({
					title: "开始识别"
				})
				this.$util.doGet(
					`/api/yun-bag/equipment/spread-qr-equipment/analysis/info?qrContent=${result}`, {}, {},
					true).then(res => {
					uni.hideLoading()
					console.log("设备信息", res.data)
					this.equipment = res.data
					if (this.equipment.id) {
						this.navTo(
							`/pages/index/equipment-info/equipment-info?equipment=${JSON.stringify(this.equipment)}`
							)
					} else {
						this.$util.showInfoToast("没有识别到设备信息")
					}
				}).catch(error => {
					console.log(error)
					uni.hideLoading()
				})
			},
			async queryList() {
				//组件加载时会自动触发此方法，因此默认页面加载时会自动触发，无需手动调用
				//这里的pageNo和pageSize会自动计算好，直接传给服务器即可
				//模拟请求服务器获取分页数据，请替换成自己的网络请求
				const list = await this.getMicInforList(this.consultPage)
				this.articleList = this.articleList.concat(list);
			},
			itemClick(index, info) {
				this.articleIndex = index
				this.$util.saveDynamicConsultation(info)
				this.navTo("/pages/index/article/article")
			},
			dialogConfirm() {
				uni.makePhoneCall({
					phoneNumber: this.phoneNumber.replace(/\s+/g, "-")
				});
			},
			dialogClose() {
				this.initial = "initial"
			},
			navTo(url) {
				if (this.labelCount === 0) {
					this.navTo("/pages/index/interest/interest")
					return;
				}
				if(!this.userInfo.phonenumber&&this.isAndroid){
					url = "/pages/user/my-setting/update-Phone/update-Phone"
				}
				if(!this.hasUserInfo){
					if(url.indexOf("nearby-facility") != -1 || url.indexOf("article") != -1){
						
					}else {
						url = "/pages/login/login"
					}
				}
				uni.navigateTo({
					url: url
				})
			},
			reLaunch(url, types) {
				getApp().globalData.types = types;
				uni.switchTab({
					url: url
				})
			},
			switchTabs(data) {
				if(data.index === 2 && !this.isAndroid){
					this.scan();
					return
				}
				if(!this.hasUserInfo){
					uni.navigateTo({
						url: "/pages/login/login"
					})
					return;
				}
				if (this.labelCount === 0) {
					uni.reLaunch({
						url: "/pages/index/interest/interest"
					})
					return;
				}
				uni.switchTab({
					url: data.url
				})
			},
			interval() {
				this.timerGif = setTimeout(() => {
					this.isGif = true
					this.gifUrl = "/static/index/money.gif"
				}, 1000)
				this.timerAnimation = setTimeout(() => {
					this.animation = ''
					this.isGif = false
					this.gifUrl = ""
				}, 3000)
			}
		},
		beforeDestroy() {
			clearInterval(this.timerShake);
			this.timerShake = null;
			clearInterval(this.timerAnimation);
			this.timerAnimation = null;
			clearInterval(this.timerGif);
			this.timerGif = null;
		}
	}
</script>

<style lang="scss">
	page {}
	
	.ad-content-page{
		flex: 1
	}

	.centre-top {
		position: fixed;
		z-index: 2;
		background-color: $index-bg-top;
		width: 100%;
		height: 110rpx;
		top: 0rpx;
		// padding-top: ;
		padding: 5rpx 0rpx;

		.search {
			width: 500rpx;
			padding: 20rpx 20rpx;
			background-color: #189FF9;
			border-radius: 50rpx;
			align-content: center;
		}
	}

	.centre-top1 {
		width: 100%;
		height: 320rpx;
		position: relative;
		z-index: -1;
		overflow: hidden;
	}

	.centre-top1:after {
		content: '';
		width: 120%;
		height: 320rpx;
		position: absolute;
		left: -10%;
		top: 0;
		z-index: -1;
		border-radius: 0 0 60% 60%;
		background: $index-bg-top;
	}


	.advertising {

		justify-content: space-around;
		align-items: center;
		padding: 15rpx 0rpx;

		image {
			width: 130rpx;
		}

		.button {
			padding: 15rpx 30rpx;
			background-color: $index-bg-top;
			border-radius: 35rpx;
			font-size: 24rpx;
			color: #FFFFFF;
		}

		.column {
			width: 298rpx;
			justify-content: flex-end;
			height: 100rpx;
		}
	}

	.advertising-img {
		width: 720rpx;
		background-color: #C0C0C0;
		text-align: center;
		border-radius: 35rpx;
		height: 300rpx;
		margin-top: 50rpx;
	}

	.centre-grid {
		padding: 0rpx 30rpx;
		position: relative;
		top: -20rpx;

		.row {
			position: relative;
			align-items: center;
			justify-content: space-around;
			bottom: 40rpx;
		}

		.animation-shake {
			animation: shake 1s !important;
		}

		@keyframes shake {

			0%,
			65% {
				-webkit-transform: rotate(0deg);
				transform: rotate(0deg);
			}

			70% {
				-webkit-transform: rotate(10deg);
				transform: rotate(10deg);
			}

			75% {
				-webkit-transform: rotate(-10deg);
				transform: rotate(-10deg);
			}

			80% {
				-webkit-transform: rotate(10deg);
				transform: rotate(10deg);
			}

			85% {
				-webkit-transform: rotate(-10deg);
				transform: rotate(-10deg);
			}

			90% {
				-webkit-transform: rotate(10deg);
				transform: rotate(10deg);
			}

			95% {
				-webkit-transform: rotate(-10deg);
				transform: rotate(-10deg);
			}

			100% {
				-webkit-transform: rotate(0deg);
				transform: rotate(0deg);
			}
		}

		.column {
			justify-content: flex-end;
			align-items: center;
			height: 220rpx;

			image {
				width: 120rpx;
				height: 120rpx;
			}

			.text-18 {
				font-size: 24rpx;
			}

		}
	}

	.text-sm {
		font-size: 26rpx;
		color: #D72816;
		margin-top: 15rpx;
	}

	.text-lg {
		font-size: 34rpx;
	}

	.article-list {
		image {
			width: 230rpx;
			height: 150rpx;
			border-radius: 20rpx;
		}

		.column-article {
			width: 450rpx;
			margin-left: 20rpx;
			height: 140rpx;
			justify-content: space-between;
		}

		.label {
			height: 90rpx;
			overflow: hidden;
			text-overflow: clip;
			display: -webkit-box;

			&:before {
				content: attr(contents);
				padding: 5rpx 10rpx;
				text-align: center;
				background-color: $index-bg-top;
				border-radius: 5rpx;
				font-size: 24rpx;
				color: #FFFFFF;
				margin-right: 10rpx;
			}
		}

		.label-text {
			text {
				font-size: 22rpx;
			}

			text:nth-child(-n+3) {
				color: #C0C0C0;
			}
		}
	}
</style>
